package com.drako.tdgdx.helper;

import com.badlogic.gdx.InputAdapter;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.math.Vector3;


	public class CamController extends InputAdapter {
		final Camera camera;
		final Vector3 curr = new Vector3();
		final Vector3 last = new Vector3(-1, -1, -1);	
		final Vector3 delta = new Vector3();
		final float speed= 100;
		
		public CamController(Camera camera) {
			this.camera = camera;
		}

		@Override public boolean touchDragged (int x, int y, int pointer) {
			camera.unproject(curr.set(x, y,0));
			if(!(last.x == -1 && last.y == -1 && last.z == -1)) {
				camera.unproject(delta.set(last.x, last.y, 0));			
				delta.sub(curr);
				camera.position.add(delta.x*speed, delta.y*speed, 0);
			}
			last.set(x, y, 0);
			return false;
		}
		
		@Override public boolean touchUp(int x, int y, int pointer, int button) {
			last.set(-1, -1, -1);
			return false;
		}
	}

